package com.mccrea.pattern.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname SubscriptSubject
 * @Description 具体被观察者
 * @Date 2021/5/21 0021 17:15
 * @Created by Mccrea_Gao
 */
public class SubscriptSubject implements Subject {

    private List<Observer> weixinUserList = new ArrayList<>();

    @Override
    public void attach(Observer observer) {
        weixinUserList.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        weixinUserList.remove(observer);
    }

    @Override
    public void notify(String message) {
        weixinUserList.forEach(u -> u.update(message));
    }
}
